﻿using System.Collections;
using System.Collections.Generic;
using PMS.IRepository;
using PMS.IServices;
using PMS.Models.Base;
using PMS.Repository;
using PMS.Utils;

namespace PMS.Services
{
    public class User_PowerService : IUser_PowerService
    {
        IUser_PowerRepository _user_PowerRepository = new User_PowerRepository();

        #region 公共方法

        public int Add(User_Power user)
        {
            return _user_PowerRepository.Add(user);
        }

        public int Edit(User_Power user)
        {
            return _user_PowerRepository.Edit(user);
        }

        public User_Power Dtl(int id)
        {
            return _user_PowerRepository.Dtl(id);
        }

        public bool IsExists(int id)
        {
            return _user_PowerRepository.IsExists(id);
        }

        public int Delete(int id, string deleteBy)
        {
            return _user_PowerRepository.Delete(id, deleteBy);
        }

        public int Delete(int[] ids, string deleteBy)
        {
            return _user_PowerRepository.Delete(ids, deleteBy);
        }

        public List<User_Power> GetList()
        {
            return _user_PowerRepository.GetList();
        }

        #endregion

        public List<User_Power> GetList(Hashtable ht)
        {
            string strWhere = string.Empty;
            Dictionary<string, object> param = new Dictionary<string, object>();
            if (ht.IsNullOrEmptyByKey("UserName"))
            {
                strWhere += " And UserName like @UserName ";
                param.Add("@UserName", ht["UserName"]);
            }

            if (ht.IsNullOrEmptyByKey("IsDel"))
            {
                strWhere += " And IsDel = @IsDel ";
                param.Add("@IsDel", ht["IsDel"]);
            }
            else
            {
                strWhere += " And IsDel = 0 ";
            }

            string strSql = "Select * from User_Power where 1=1" + strWhere;

            return _user_PowerRepository.GetList(strSql, param);

        }
    }
}